#ifndef CAMERA_H
#define CAMERA_H

#include "ICamera.h"
#include "EventManager.h"

namespace glow
{
	class Camera : public ICamera
	{
		public:

            /**
             *  Default Constructor
             **/
			Camera();

			/**
			 *  Constructor with position of the camera in parameter
			 *\param the position of the camera
			 **/
			Camera(Vector3d pos = Vector3d());

			/**
			 *  Destroy the camera
			 **/
			virtual ~Camera();


            /**
             *  Set the defaults keys to move the camera in the 3d-space
             **/
			void setDefaultKeyMap();

			/**
			 *  Set the keys to move the camera in the 3d-space
			 *\param the keymap of the camera
			 **/
			void setKeyMap(const KeyMap &kmap);

            /**
             *  Get the position of the camera
			 *\return the position of the camera
             **/
			const Vector3d &getPosition() const;

			/**
			 *  Get the angle of the camera
			 *\return the angle of the camera
			 **/
			const Vector3d &getAngle() const;

			/**
			 *  Get the position of the target of the camera
			 *\return the position target by the camera
			 **/
			const Vector3d &getTarget() const;

            /**
             *  Set the position of the camera
			 *\param the position of the camera
             **/
			void setPosition(Vector3d pos);

            /**
			 *  Set the angle of the camera
			 *\param the angle of the camera
			 **/
			void setAngle(Vector3d ang);

            /**
			 *  Set the position of the target of the camera
			 *\param the position target by the camera
			 **/
			void setTarget(Vector3d targ);


			/**
			 *  Change the speed of movement of the camera
			 *  Note : the speed equals the parameter. That not increment.
			 *\param the speed's movement of the camera
			 **/
			void setSpeed(double speed);

			/**
			 *  Change the sensitivity of the camera
			 *  Note : the sensitivity equals the parameter. That not increment.
			 *\param the sensitivity of the camera
			 **/
			void setSensivity(double sensivity);

            /**
             * Reset all attribute of the camera
             **/
			void reset();

			/**
			 * Set the parameters in the camera attributes and show
			 *\param the position of the camera
			 *\param the position target by the camera
			 *\param the angle of the camera
			 **/
			void lookAt(Vector3d pos, Vector3d targ, Vector3d ang);

			/**
			 * Show with the camera attributes
			 **/
			void look();

            /**
             * Find the event bind with the camera
             **/
			void getEvent();

			/**
			 *  Update attributes with the event find
			 **/
			void animate();

		private:

			void VectorsFromAngles();

            /**
             *  Position of the camera
             **/
			Vector3d _position;

            /**
             *  Angle of the camera
             **/
			Vector3d _angle;

            /**
             *  Target position of the camera
             **/
			Vector3d _target;

			/**
			 *
			 **/
			Vector3d _forward;

			/**
			 *
			 **/
			Vector3d _left;

			/**
			 *  Table of the events bind with this camera
			 **/
			KeyMap _kmap;

			/**
			 *  Table of the events activated
			 **/
			KeyStates _keystates;

			/**
			 *  Speed movement of the camera
			 **/
			double _speed;

			/**
			 *  Sensitivity of the camera
			 **/
			double _sensivity;

			/**
			 *
			 **/
			double _phi;

			/**
			 *
			 **/
			double _theta;

			/**
			 *  Current time
             **/
			double _now;

			/**
			 *  Time of the last animation
			 **/
			double _start_time;

			/**
			 *  Time ellapsed since the last animation
			 **/
			double _time_step;

	};
}

#endif
